/*
 * @lc app=leetcode id=205 lang=cpp
 *
 * [205] Isomorphic Strings
 */
class Solution {
public:
    bool isIsomorphic(string s, string t) {
        
        int slen = s.size();
        int tlen = t.size();
        if (slen != tlen) {
            return false;
        }
        unordered_map<char, char> charMap;
        for (int i=0; i<slen; i++) {
            if (!charMap[s[i]] && !charMap[t[i]]) {
                charMap[s[i]] = t[i];
                charMap[t[i]] = s[i];
            } else if (charMap[s[i]] != t[i] || charMap[t[i]] != s[i]) {
                return false;
            }
        }
        return true;
    }
};

